package cn.arrow.note.validation.entity.dto;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.util.List;

/**
 * @author zimo
 * @date 2021-11-28
 **/

@Data
public class UserDTO {

    /**
     * 在更新时校验id
     */
    @NotBlank(message = "id不能为空", groups = Update.class)
    private String id;

    @NotBlank(message = "用户名不能为空")
    @Length(min = 2, max = 20)
    private String username;

    @NotBlank(message = "密码不能为空")
    @Length(min = 8, max = 20)
    private String password;

    @Email(message = "邮箱格式不正确")
    private String email;

    @NotNull(message = "部门信息不能为空")
    @Valid
    private List<DepartmentDTO> departments;

    /**
     * 更新分组
     */
    public static class Update implements Default {
    }

}
